<?php



namespace App\Services\Other\Services;


use App\Services\Base\Services\ConfigService;
use App\Services\Other\Interfaces\ChannelServiceInterface;
use App\Services\Base\Interfaces\ConfigServiceInterface;
use Illuminate\Support\Facades\DB;

class ChannelService implements ChannelServiceInterface
{
    /**
     * @var ConfigService
     */
    protected $configService;

    public function __construct(ConfigServiceInterface $configService)
    {
        $this->configService = $configService;
    }


    public function insertFragmentImages(int $fragmentId, array $data)
    {

        $images = [];
        foreach ($data as $k => $i) {
            $images[$k]['fragment_id'] = $fragmentId;
            $images[$k]['channel_id'] = $i['channel_id'];
            $images[$k]['title'] = $i['title'];
            $images[$k]['url'] = $i['url'];

        }

        DB::table('channel_fragment_images')->insert($images);
        return 'success';

    }
    public function insertFragmentVideo(int $fragmentId, array $data)
    {


        $video=[
            'fragment_id' => $fragmentId,
            'channel_id' => $data['channel_id'],
            'title'=>$data['title'],
            'url'=>$data['url'],
            'thumb'=>$data['thumb'],
            'duration'=>$data['duration'],
        ];
        DB::table('channel_fragment_videos')->insert($video);


    }


}
